#pragma once
#include "MediaSource.h"


namespace jlh
{
	class AACSource : public MediaSource
	{
	public:
		static AACSource* CreateNew(uint32_t samplerate, uint32_t channels, bool has_adts);
		virtual ~AACSource();

		uint32_t GetSamplerate() const
		{
			return samplerate_;
		}

		uint32_t GetChannels() const {
			return channels_;
		}

		std::string GetMediaDescription(uint16_t port = 0) override;
		std::string GetAttribute() override;
		bool HandleFrame(MediaChannelId channelId, AVFrame frame) override;

		static uint32_t GetTimestamp(uint32_t samplerate = 44100);

	private:
		AACSource(uint32_t samplerate, uint32_t channels, bool has_adts);

	private:
		uint32_t samplerate_ = 44100;
		uint32_t channels_ = 2;
		bool has_adts_ = true;

		static const int ADTS_SIZE = 7;
		static const int AU_SIZE = 4;
	};
}


